<?php

/**
 * ContactForm class.
 * ContactForm is the data structure for keeping
 * contact form data. It is used by the 'contact' action of 'SiteController'.
 */
class User extends ActiveRecord
{
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
	
	public function tableName()
	{
		return 'user';
	}
	
	public function rules()
	{
		return array(
		);
	}

	public function search()
	{
		$query = "SELECT * 
			FROM user t
		";
		
		$result = $this -> executeAllTotal($query, array(), false, "t.createdDate DESC");
	
		return $result;
	}
	
        public function login($username, $password)
        {
            $result = null;
            
            try{
                $query = "
                    SELECT * 
                    FROM user 
                    where username = :username
                ";

                $result = $this -> executeRow($query, array(':username' => $username));
                
                if($result['password'] != $password)
                {
                    $result = null;
                }
            }
            catch(Exception $ex){
                
            }
            
            return $result;
        }	
        

}